<?php

$CFetchers->fetchLstDataHeader($Db,
                               $jobId,
                               $SourceDb->fetchValue("srcDbHdr"),
                               $nHeader,
                               $lstHeader);

$_POST["trDateEnt"]     = date("d-m-Y",
                               strtotime($lstHeader["TR_DATE"][0]));

$_POST["notaSrcEnt"]    = $lstHeader["NOTA_SRC"][0];
$_POST["srcWhs"]        = $lstHeader["SRC_WHS"][0];

$CLFetchers->fetchLstDataDetail($Db,
                                $jobId,
                                $SourceDb,
                                $nDetail,
                                $lstDetail);

for($iRow = 0; $iRow < $nDetail; $iRow++){

  $_POST["modelEnt"][$iRow]  = $lstDetail["MODEL"][$iRow];
  $_POST["qtyEnt"][$iRow]    = $lstDetail["QTY"][$iRow];
  $_POST["headEnt"][$iRow]   = $lstDetail["HEAD"][$iRow];
  $_POST["lengthEnt"][$iRow] = $lstDetail["LENGTH"][$iRow];
  $_POST["serNumEnt"][$iRow] = $lstDetail["SER_NUM"][$iRow];
}

echo  /**
      * Global header
      *
      */
      "<table border='1' class='dedeq' >\n".
      "<tr>\n".

        "<td class='solid'> DATE </td>
            <td > ".date("d-m-Y",
                         strtotime($_POST["trDateEnt"]))." </td> \n".

      "</tr>\n".
      "<tr>\n".

        "<td class='solid'> NOTA SOURCE </td>
          <td> ".$_POST["notaSrcEnt"]." </td>\n".

      "</tr>\n".

      $GHtml->formHidden("srcWhs",
                         $_POST["srcWhs"],
                         _NO_PROPERTY).

      "</table><br/>\n";

/**
 * init the details
 */
require("controllers/initDetails.php");

echo  "<table border='1' class='dedeq'>\n".
      "<tr>\n".
      "<th> No    </th>\n".
      "<th> Model </th>\n".
      "<th> Qty </th>\n".
      "<th> SN    </th>\n".
      "</tr>\n";

/**
 * @see controllers/initDetails.php
 * @var nDetail
 */
for($iRow = 0; $iRow < $nDetail ; $iRow++){

  $_POST["rowId"][$iRow] = date("hi") . $iRow;

  if($_POST["isSNed"][$iRow]){

    $additional = " <td> ".$_POST["headEnt"][$iRow]."  </td>

                    <td> ".$_POST["lengthEnt"][$iRow]."  </td>

                    <td> ".$_POST["serNumEnt"][$iRow]."  </td> ";
  }else{

    $additional = " <td> 0 </td>

                    <td> 0 </td>

                    <td> ".$_POST["serNumEnt"][$iRow]."  </td> ";
  }

  //$lstModel = $Misc->retArray($_POST["modelEnt"][$iRow]);

  echo  "<tr>\n".

        "<td> ".($iRow + 1)." </td>\n".

        "<td> ".$_POST["modelEnt"][$iRow]." </td>\n".

        "<td> ".$_POST["qtyEnt"][$iRow]." </td>\n".

        "<td> <table border='1' class='dedeq'>

              ".$additional."

              </table>
              </td>\n".

        "</tr>\n";
}

echo  "</table><br/>\n";
?>